<?php
/**
 * Created by PhpStorm.
 * User: Raytine
 * Date: 2018/8/30
 * Time: 15:02
 */
namespace PddWechat\Models\User\Data;

use PddWechat\Models\User\Dao\WithdrawCashDao;
use PddWechat\Models\User\DataObject\UserWithdrawDo;
use PddWechat\Models\User\Param\UserWithdrawListParam;


class WithdrawCashData
{
    public function __construct()
    {
        $this->withdrawCashDao = new WithdrawCashDao();
        $this->userData = new UserData();
    }

    public function insert(UserWithdrawDo $userWithdrawDo) {
        return $this->withdrawCashDao->insert($userWithdrawDo);
    }

    public function withDrawMoney(UserWithdrawDo $userWithdrawDo, $uid, $money) {
        $this->withdrawCashDao->begin();
        $this->insert($userWithdrawDo);
        $this->userData->updateUserWithDrawMoney($uid, $money);
        $this->withdrawCashDao->commit();
        return true;
    }

    public function updateStatusById(int $id) {
        return $this->withdrawCashDao->updateStatusById($id);
    }

    public function selectUserWithdrawList(UserWithdrawListParam $params) {
        return $this->withdrawCashDao->selectUserWithdrawList($params);
    }

    public function selectUserWithdrawNum() {
        return $this->withdrawCashDao->selectUserWithdrawNum();
    }

    public function selectUserWithdrawDataByUid(int $uid, int $status) {
        return $this->withdrawCashDao->selectUserWithdrawDataByUid($uid, $status);
    }

    public function selectUserWithdrawListByUid(int $uid) {
        return $this->withdrawCashDao->selectUserWithdrawListByUid($uid);
    }

}